function envia_ajax(metodo, url, usaXml, dados, callback) {
	var httpRequest;
	
	if (window.XMLHttpRequest) {
		httpRequest = new XMLHttpRequest();
		if(usaXml && httprequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
		}
	}
	
	else if (window.ActiveXObject){
		try{
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){}
		}
	}
	
	if (!httpRequest){
		alert('Erro fatal :( N~ao consigo criar um objeto XMLHttpRequest');
		return false;
	}
	
	httpRequest.open(metodo, url, true);
	
	if (callback != null) {
		httpRequest.onreadystatechange = function() {
			retorna_ajax(metodo, url, httpRequest, callback);
		};
	}
	
	if (metodo == 'POST' && dados != null) {
		httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	}
	
	httpRequest.send(dados);
}

function retorna_ajax (metodo, url, httpRequest, callback) {
	if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {
			if (callback != null){
				callback(httpRequest);
			}
		}
		else {
			alert('Erro de AJAX: ' + httpRequest.status + '\n' + metodo + ': ' + url);
		}
	}
}